package com.git_taoxian.test3;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Test3 {
    public static void main(String[] args) {
        double[] arr = {0.1,0.2,2.1,3.2,5.56,7.21};
        double num = 0.0;
        BigDecimal tempNum = BigDecimal.valueOf(num);
        for (int i = 0; i < arr.length; i++) {
            tempNum = tempNum.add(BigDecimal.valueOf(arr[i]));
        }
        BigDecimal len = BigDecimal.valueOf(arr.length);
        BigDecimal rs = tempNum.divide(len, 2, RoundingMode.FLOOR);
        System.out.println("数的平均值是："+rs);
    }
}
